﻿#include "filecontroller.h"
#include <responesutils.h>

FileController::FileController(QObject *parent) : HttpController(parent)
{

}

FileController::~FileController()
{

}

void FileController::route(QString path, QString method, HttpRequest &request, HttpResponse &response)
{
    if (method == "GET")
    {
        if (path == "download")
        {
            return download(request, response);
        }
    }
}

void FileController::download(HttpRequest &request, HttpResponse &response)
{
    QString filePath = request.getParameter("url");
    qDebug() << "----------------------" << filePath;
    return ResponesUtils::downloadFileResponse(response,filePath,"file");
}
